<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="./tab.css">

</head>

<body>
  <div id="tab">
    <ul id="nav">
      <li class="active">首页</li>
      <li>男人</li>
      <li>女人</li>
    </ul>
    <div id="content">
      <div>首页内容</div>
      <div>男人内容</div>
      <div>女人内容</div>
    </div>
  </div>
</body>
<script>

  // var tab = new Tab("#tab")

  var lis = document.querySelectorAll("#nav li");
  var divs = document.querySelectorAll("#content>div")
  for (var i = 0; i < lis.length; i++) {
    lis[i].index = i;
    lis[i].onclick = function () {
      for (var j = 0; j < lis.length; j++) {
        lis[j].className = ""
        divs[j].style.display = "none"
      }
      this.className = "active";
      divs[this.index].style.display = "block"
    }
  }


</script>

</html>